<include file="Public/head" />

<body>
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> {:L("shangpinfenlei")}</strong></div>
    <div class="padding border-bottom">
      <a class="button border-main icon-plus-square-o" href="{:U('Goodscate/edit')}"> {:L("tianjia")}</a>
    </div>
    <table class="table table-hover text-center">
      <tr>
        <th width="10%">{:L("paixu")}</th>
        <th width="20%">{:L("fenleibiaoti")}</th>
        <th width="10%">{:L("xianshi")}</th>
        <th width="10%">{:L("caozuo")}</th>
      </tr>
      <foreach name="list" item="v">
        <tr class="o{$v['goods_cate_id']}">
          <td>{$v['sort']}</td>
          <td>{$v['goods_cate_name']}</td>
          <td>
            <span class="sp01" onclick="is_show({$v['goods_cate_id']},this)">
              <if condition="$v['is_show'] == 1">
                <img src="__PUBLIC__/web/images/yes.png" width="18px;" >
                <else />
                <img src="__PUBLIC__/web/images/no.png" width="18px;" >
              </if>
            </span>
          </td>
          <td>
            <div class="button-group">
              <a class="button border-main" href="{:U('Goodscate/edit',array('id'=>$v['goods_cate_id']))}"><span class="icon-edit"></span> {:L("bianji")}</a>
              <a class="button border-red" href="javascript:void(0)" onclick="return del({$v['goods_cate_id']})"><span class="icon-trash-o"></span> {:L("shanchu")}</a>
            </div>
          </td>
        </tr>
      </foreach>
    </table>
  </div>
  <script type="text/javascript">
    function del(id){
      if(confirm("{:L('shanchuxiaoxi')}")){
        var url = "{:U('Goodscate/delete')}";
        $.getJSON(url,{id:id},function (data){
          if(data.result == 'tp1'){$(".o"+id).remove();}
          else if(data.result == 'break'){alert('ERROR.');}
        })
      }
    }
    function is_show(id,t){
      var url = "{:U('Goodscate/is_show')}";
      $.getJSON(url,{id:id},function (data){
        if(data.result == 'yes'){
          $(t).find('img').attr('src',"__PUBLIC__/web/images/yes.png");
        }else if(data.result == 'no'){
          $(t).find('img').attr('src',"__PUBLIC__/web/images/no.png");
        }
      })
    }
  </script>
</body>

</html>